Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Chip] Add ripple when clickable #17829

Merged
merged 4 commits into from
Oct 30, 2019
Merged

[Chip] Add ripple when clickable #17829

merged 4 commits into from
Oct 30, 2019

Conversation

Tarun047
Copy link
Contributor

@Tarun047 Tarun047 commented Oct 10, 2019

Updated Chip Component to use Button Base.
This enables the Repl Effect for the Chip component.

Fixes #17718

@mui-pr-bot
Copy link

mui-pr-bot commented Oct 10, 2019

Details of bundle changes.

Comparing: 5d564f9...5e4abf3

bundle Size Change Size Gzip Change Gzip
Chip ▲ +11.8 kB (+16.76% ) 82.5 kB ▲ +3.96 kB (+18.21% ) 25.7 kB
@material-ui/core ▼ -190 B (-0.05% ) 347 kB -- 95.2 kB
@material-ui/core[umd] ▼ -146 B (-0.05% ) 307 kB ▼ -32 B (-0.04% ) 88.3 kB
ButtonBase ▼ -2 B (-0.00% ) 73.8 kB ▲ +2 B (+0.01% ) 23.1 kB
Paper ▲ +1 B (0.00% ) 62.4 kB ▼ -5 B (-0.03% ) 19.3 kB
Collapse -- 67.8 kB ▼ -8 B (-0.04% ) 20.9 kB
@material-ui/lab -- 145 kB ▲ +6 B (+0.01% ) 45 kB
ListItem -- 77 kB ▲ +6 B (+0.03% ) 24 kB
MenuItem -- 78 kB ▲ +6 B (+0.02% ) 24.3 kB
Drawer -- 84.3 kB ▼ -5 B (-0.02% ) 26 kB
SpeedDial -- 85.9 kB ▲ +5 B (+0.02% ) 27 kB
SwipeableDrawer -- 90.7 kB ▲ +5 B (+0.02% ) 28 kB
SpeedDialAction -- 115 kB ▲ +4 B (+0.01% ) 36.4 kB
Tooltip -- 99.1 kB ▼ -4 B (-0.01% ) 31.4 kB
ExpansionPanel -- 71.1 kB ▲ +3 B (+0.01% ) 22.1 kB
OutlinedInput -- 73.7 kB ▼ -3 B (-0.01% ) 22.9 kB
Toolbar -- 62.3 kB ▼ -3 B (-0.02% ) 19.4 kB
AppBar -- 63.9 kB ▲ +2 B (+0.01% ) 19.9 kB
BottomNavigationAction -- 75.3 kB ▼ -2 B (-0.01% ) 23.8 kB
Box -- 70.8 kB ▲ +2 B (+0.01% ) 21.4 kB
Dialog -- 82.5 kB ▲ +2 B (+0.01% ) 25.6 kB
Fade -- 23.1 kB ▲ +2 B (+0.02% ) 8.05 kB
FilledInput -- 73.1 kB ▲ +2 B (+0.01% ) 22.6 kB
Grow -- 23.7 kB ▼ -2 B (-0.02% ) 8.16 kB
Hidden -- 66.1 kB ▼ -2 B (-0.01% ) 20.6 kB
InputBase -- 70.2 kB ▲ +2 B (+0.01% ) 22 kB
Menu -- 88.3 kB ▲ +2 B (+0.01% ) 27.6 kB
NativeSelect -- 76.4 kB ▼ -2 B (-0.01% ) 24 kB
Popover -- 82.6 kB ▼ -2 B (-0.01% ) 25.4 kB
Radio -- 82.5 kB ▲ +2 B (+0.01% ) 25.9 kB
Slide -- 25.1 kB ▲ +2 B (+0.02% ) 8.68 kB
Snackbar -- 77.1 kB ▲ +2 B (+0.01% ) 24 kB
StepButton -- 82.1 kB ▲ +2 B (+0.01% ) 25.8 kB
StepConnector -- 62.7 kB ▼ -2 B (-0.01% ) 19.6 kB
SvgIcon -- 63 kB ▼ -2 B (-0.01% ) 19.6 kB
Zoom -- 23.1 kB ▲ +2 B (+0.02% ) 8.06 kB
Avatar -- 62.7 kB ▼ -1 B (-0.01% ) 19.6 kB
Backdrop -- 67.7 kB ▼ -1 B (-0.00% ) 20.9 kB
BottomNavigation -- 62.4 kB ▼ -1 B (-0.01% ) 19.5 kB
Breadcrumbs -- 68 kB ▼ -1 B (-0.00% ) 21.3 kB
Button -- 79.3 kB ▲ +1 B (0.00% ) 24.5 kB
ButtonGroup -- 64.2 kB ▼ -1 B (-0.01% ) 20 kB
CardActions -- 62 kB ▼ -1 B (-0.01% ) 19.3 kB
CardContent -- 62 kB ▼ -1 B (-0.01% ) 19.3 kB
CardHeader -- 65.1 kB ▼ -1 B (-0.00% ) 20.4 kB
CardMedia -- 62.4 kB ▼ -1 B (-0.01% ) 19.5 kB
CircularProgress -- 64.1 kB ▼ -1 B (-0.00% ) 20.1 kB
Container -- 63.1 kB ▼ -1 B (-0.01% ) 19.6 kB
DialogContentText -- 64 kB ▼ -1 B (-0.00% ) 20 kB
DialogTitle -- 64.3 kB ▼ -1 B (-0.00% ) 20.1 kB
ExpansionPanelActions -- 62.1 kB ▼ -1 B (-0.01% ) 19.4 kB
ExpansionPanelSummary -- 77.9 kB ▼ -1 B (-0.00% ) 24.5 kB
Fab -- 76.7 kB ▲ +1 B (0.00% ) 23.8 kB
FormControl -- 64.3 kB ▼ -1 B (-0.01% ) 19.9 kB
FormControlLabel -- 65.5 kB ▼ -1 B (-0.00% ) 20.5 kB
FormGroup -- 62 kB ▼ -1 B (-0.01% ) 19.3 kB
FormHelperText -- 63.3 kB ▼ -1 B (-0.01% ) 19.7 kB
FormLabel -- 63.3 kB ▼ -1 B (-0.01% ) 19.5 kB
Grid -- 65.1 kB ▼ -1 B (-0.00% ) 20.3 kB
GridList -- 62.5 kB ▼ -1 B (-0.01% ) 19.5 kB
GridListTile -- 63.7 kB ▼ -1 B (-0.01% ) 19.9 kB
GridListTileBar -- 63.2 kB ▼ -1 B (-0.01% ) 19.7 kB
Icon -- 62.8 kB ▼ -1 B (-0.01% ) 19.6 kB
IconButton -- 76 kB ▲ +1 B (0.00% ) 23.7 kB
Input -- 72 kB ▲ +1 B (0.00% ) 22.4 kB
InputAdornment -- 65.1 kB ▼ -1 B (-0.00% ) 20.4 kB
InputLabel -- 65.1 kB ▼ -1 B (-0.00% ) 20.2 kB
LinearProgress -- 65.3 kB ▼ -1 B (-0.00% ) 20.3 kB
List -- 62.4 kB ▲ +1 B (+0.01% ) 19.3 kB
ListItemIcon -- 62.2 kB ▼ -1 B (-0.01% ) 19.4 kB
ListItemText -- 65 kB ▼ -1 B (-0.00% ) 20.4 kB
ListSubheader -- 62.8 kB ▼ -1 B (-0.01% ) 19.6 kB
MenuList -- 66 kB ▲ +1 B (0.00% ) 20.6 kB
MobileStepper -- 67.7 kB ▼ -1 B (-0.00% ) 21.1 kB
NoSsr -- 2.19 kB ▼ -1 B (-0.10% ) 1.04 kB
RadioGroup -- 63.2 kB ▼ -1 B (-0.01% ) 19.7 kB
Rating -- 69.8 kB ▼ -1 B (-0.00% ) 22.2 kB
RootRef -- 4.43 kB ▼ -1 B (-0.06% ) 1.67 kB
Skeleton -- 62.5 kB ▼ -1 B (-0.01% ) 19.6 kB
Slider -- 75.3 kB ▼ -1 B (-0.00% ) 23.7 kB
SnackbarContent -- 65.8 kB ▼ -1 B (-0.00% ) 20.6 kB
Step -- 62.6 kB ▼ -1 B (-0.01% ) 19.6 kB
StepContent -- 69 kB ▲ +1 B (0.00% ) 21.4 kB
StepIcon -- 64.7 kB ▼ -1 B (-0.00% ) 20.1 kB
StepLabel -- 68.6 kB ▼ -1 B (-0.00% ) 21.4 kB
Switch -- 80.8 kB ▲ +1 B (0.00% ) 25.1 kB
Tab -- 76.2 kB ▼ -1 B (-0.00% ) 24.1 kB
Table -- 62.6 kB ▼ -1 B (-0.01% ) 19.5 kB
TableBody -- 62.1 kB ▼ -1 B (-0.01% ) 19.3 kB
TableCell -- 64.1 kB ▼ -1 B (-0.00% ) 20.1 kB
TableFooter -- 62.1 kB ▼ -1 B (-0.01% ) 19.3 kB
TableHead -- 62.1 kB ▼ -1 B (-0.01% ) 19.3 kB
TablePagination -- 140 kB ▲ +1 B (0.00% ) 40.7 kB
TableRow -- 62.5 kB ▼ -1 B (-0.01% ) 19.5 kB
Tabs -- 85.3 kB ▲ +1 B (0.00% ) 27.1 kB
TextField -- 121 kB ▼ -1 B (-0.00% ) 35.4 kB
ToggleButton -- 76 kB ▼ -1 B (-0.00% ) 23.9 kB
ToggleButtonGroup -- 63.2 kB ▼ -1 B (-0.01% ) 19.8 kB
TreeItem -- 73.4 kB ▲ +1 B (0.00% ) 23.1 kB
TreeView -- 66 kB ▼ -1 B (-0.00% ) 20.6 kB
Typography -- 63.7 kB ▼ -1 B (-0.01% ) 19.8 kB
@material-ui/styles -- 51.8 kB -- 15.6 kB
@material-ui/system -- 15.7 kB -- 4.37 kB
Badge -- 65.4 kB -- 20.2 kB
Card -- 62.9 kB -- 19.6 kB
CardActionArea -- 74.9 kB -- 23.6 kB
Checkbox -- 81.6 kB -- 25.6 kB
ClickAwayListener -- 3.85 kB -- 1.55 kB
colorManipulator -- 3.83 kB -- 1.52 kB
CssBaseline -- 57.6 kB -- 18 kB
DialogActions -- 62.1 kB -- 19.4 kB
DialogContent -- 62.2 kB -- 19.4 kB
Divider -- 62.6 kB -- 19.6 kB
docs.landing -- 54.8 kB -- 14.5 kB
docs.main -- 599 kB -- 191 kB
ExpansionPanelDetails -- 61.9 kB -- 19.3 kB
Link -- 66.6 kB -- 21 kB
ListItemAvatar -- 62.1 kB -- 19.4 kB
ListItemSecondaryAction -- 62 kB -- 19.3 kB
Modal -- 14.3 kB -- 4.96 kB
Popper -- 28.3 kB -- 10.2 kB
Portal -- 2.87 kB -- 1.29 kB
Select -- 113 kB -- 33.6 kB
SpeedDialIcon -- 64.6 kB -- 20.2 kB
Stepper -- 64.9 kB -- 20.3 kB
styles/createMuiTheme -- 16.3 kB -- 5.79 kB
TableSortLabel -- 77.2 kB -- 24.4 kB
TextareaAutosize -- 5.06 kB -- 2.11 kB
useMediaQuery -- 2.49 kB -- 1.05 kB

Generated by 🚫 dangerJS against 5e4abf3

@oliviertassinari oliviertassinari added the PR: needs revision The pull request can't be merged. More details is available on the code review or fails in the CI label Oct 11, 2019
@Tarun047
Copy link
Contributor Author

Hey @oliviertassinari,
I am new to this whole contributing thing,
Could you please point me in the right direction ?
I mean is using ButtonBase a good idea ?

@oliviertassinari
Copy link
Member

@Tarun047 Hey. Yes, I think that using ButtonBase is the right path to get the ripple effect. I have labeled "needs revision" because the build is failing. @mbrookes has built this component int he first place, it would be great to have his insight on the matter.

@oliviertassinari oliviertassinari added the component: chip This is the name of the generic UI component, not the React module! label Oct 13, 2019
@Tarun047
Copy link
Contributor Author

@mbrookes Could you throw some light on this issue ?

@mbrookes
Copy link
Member

You're heading in the right direction. The MD spec didn't have a ripple for the chip when this component was first created, but I'm glad to see that it was added since.

One thing to consider is under what circumstances a clicked chip should ripple. At the moment the Chip behaves differently depending on whether an onClick (or onDelete) function is provided. (This is a little different to other components, for better or worse...) You could do the same for the ripple, rather than having it always ripple when clicked.

@oliviertassinari
Copy link
Member

At the moment the Chip behaves differently depending on whether an onClick (or onDelete) function is provided.

@mbrookes Interesting. For the multi-select case, we need the chip to be focusable and to have a delete button. Vuetify can be used to benchmark: https://vuetifyjs.com/en/components/chips#chips.

Would the following work?

  • basic: no ripple, the chip is a static div
  • onClick: focus + hover styles + ripple
  • onDelete: focus + hover styles

@mbrookes
Copy link
Member

For the multi-select case, we need the chip to be focusable and to have a delete button.

That's already supported. The ripple on click is incidental to that use case.

@oliviertassinari
Copy link
Member

@mbrookes Agree, chip for multi-select is perfect right now, I don't want to have a regression :)

Copy link
Contributor Author

@Tarun047 Tarun047 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now it gives ripple effect only if onClick and not onDelete (like with multi select)

packages/material-ui/src/Chip/Chip.js Outdated Show resolved Hide resolved
@Tarun047
Copy link
Contributor Author

I made the changes, but tests are still failing due.
Can anyone help me with this ?

@mbrookes mbrookes changed the title Update Chip Component to use Repl Effect [Chip] Ripple when clicked Oct 15, 2019
@oliviertassinari oliviertassinari removed the PR: needs revision The pull request can't be merged. More details is available on the code review or fails in the CI label Oct 17, 2019
Copy link
Member

@oliviertassinari oliviertassinari left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have tried to move the pull request forward.

@oliviertassinari oliviertassinari changed the title [Chip] Ripple when clicked [Chip] Add ripple when clickable Oct 17, 2019
@Tarun047
Copy link
Contributor Author

thanks for updating the tests @oliviertassinari

@mbrookes
Copy link
Member

Should the clickable chip ripple when the delete icon is clicked?

@oliviertassinari
Copy link
Member

Should the clickable chip ripple when the delete icon is clicked?

I would say no, but what's the use case for a clickable chip with a delete icon?

@mbrookes
Copy link
Member

mbrookes commented Oct 17, 2019

It's in the spec:

image

They don't show a specific example, but I would think something like an expandable chip that can also be deleted?

@oliviertassinari
Copy link
Member

@mbrookes I have no solution to propose 🤔

@oliviertassinari
Copy link
Member

Should the clickable chip ripple when the delete icon is clicked?

Giving more thought to this problem, I would be fine if we keep the ripple: we have customization demos where the delete icon is replaced with an end leading icon. I would propose to get developers feedback before changing the behavior.

@mbrookes
Copy link
Member

we have customization demos

In the Chip playground? Perhaps a checkmark is not the best choice as an alternate delete icon?

In any case, I would suggest that if we can, we support the default use-case out-of-the-box, and wait for developer feedback on the need for an alternative. 🙂

@oliviertassinari
Copy link
Member

oliviertassinari commented Oct 19, 2019

I meant the checked icon in the very first demo:
Capture d’écran 2019-10-19 à 22 18 18

Ok, so it's good to go, as is?

@mbrookes
Copy link
Member

mbrookes commented Oct 19, 2019

I meant the checked icon in the very first demo

Oops, was too busy looking for a customisation demo!

so it's good to go, as is?

I don't think the chip should ripple when the delete icon is clicked. However, it may not be a problem in practice if the deleted chip is immediately removed from the DOM.

In other words, it only appears "wrong" in our static demos, because the chip isn't removed when delete is clicked.

The caveat here is that in the Chip spec under Behaviour / Transformative, the example image appears to show the added chip having a grow transition. This could be taken to imply that a deleted chip should have the reverse. In that case, a flash of ripple might be undesirable.

On balance, I think it's okay to merge as is, and wait to see if it's considered a problem.

@eps1lon
Copy link
Member

eps1lon commented Oct 20, 2019

I think clicking/focusing the delete button inside the chip should not bubble up i.e. stop propagating the events. Then the whole chip should stop rippling. This also makes more sense since you probably don't want the chip click handler to be executed when delete is clicked.

@oliviertassinari
Copy link
Member

oliviertassinari commented Oct 20, 2019

I would be eager to collect more user feedback on this. From a product perspective, do we have enough context?

The stop propagation could be a valid solution. I guess we would need to stop mousedown, mouseup, touchstart, touchend, & onclick.

@oliviertassinari oliviertassinari merged commit 258e847 into mui:master Oct 30, 2019
@oliviertassinari
Copy link
Member

@Tarun047 Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: chip This is the name of the generic UI component, not the React module! new feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Chip] No Ripple effect
5 participants